package com.kitty.game.gm.handler;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.admin.service.AdminService;
import com.kitty.game.equip.message.RespNotifyMiscEx;
import com.kitty.game.gm.GmService;
import com.kitty.game.role.model.Role;
import com.kitty.mina.message.MessagePusher;

public class GmJinyanOpen implements GMFather {
    @Override
    public boolean handle(Role aaa, String content) {
        String name = content;
        GmService gmService = SpringUtils.getBean(GmService.class);
        name = gmService.replaceName(name);
        Role role = SpringUtils.getRoleService().getOnlinePlayer(name);
        if (role == null) {
            long uid = gmService.getUidByName(name);
            role = SpringUtils.getRoleService().getPlayerBy(uid);
            if (role == null) {
                MessagePusher.pushMessage(aaa, new RespNotifyMiscEx("角色不存在"));
                return true;
            }
        }
        AdminService adminService = SpringUtils.getBean(AdminService.class);
        adminService.shutChannel(role, 0);
        MessagePusher.pushMessage(role, new RespNotifyMiscEx("你的禁言已经解开，可以发言！"));
        MessagePusher.pushMessage(aaa, new RespNotifyMiscEx("对方禁言已经解开"));
        return true;
    }
}
